<?php

/**
 * BaseController.class.php 自定义应用基类
 * Created Time 2016年3月9日 下午1:41:29
 *
 * @author     codingyuan@163.com
 */
namespace Common\Common;

use Think\Controller;

class CommonController extends Controller {
    public static $static = null;

    public function __construct()
    {

        parent::__construct ();
        if (is_null (self::$static))
        {
            $this->__getStaticPath ();
        }
        
        if (! $base_url = C ('base_url'))
        {
            $base_url = '/';
        }
        $this->url = $base_url;
        
        $this->assign ('css_dir', self::$static ['css_dir']);
        $this->assign ('js_dir', self::$static ['js_dir']);
        $this->assign ('img_dir', self::$static ['img_dir']);
        $this->assign ('base_url', $this->url);
    }
    
    // 获取静态文件路径
    static private function __getStaticPath()
    {

        self::$static ['css_dir'] = __ROOT__ . '/' . trim (C ('static.css_dir'), '/') . '/';
        self::$static ['js_dir'] = __ROOT__ . '/' . trim (C ('static.js_dir'), '/') . '/';
        self::$static ['img_dir'] = __ROOT__ . '/' . trim (C ('static.img_dir'), '/') . '/';
    }

    

}